import { PetManualInfo } from "../view/pet/illu/PetManualInfo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { SkillConfig } from "./SkillConfig";
type int = number;
//class PetManualConfig
    
    export  class PetManualConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (PetManualConfig._instance != null) 
            {
                throw new Error(" PetManualConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new PetManualInfo();
                loc1.category = loc2.category;
                loc1.id = loc2.id;
                loc1.type = loc2.type;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.label = loc1.name;
                loc1.info = StringHelper.getString(loc2.info);
                loc1.propertyOne = loc2.propertyOne;
                loc1.propertyTwo = loc2.propertyTwo;
                loc1.propertyThree = loc2.propertyThree;
                loc1.propertyFour = loc2.propertyFour;
                this._map[loc1.id] = loc1;
                this._map[loc1.propertyOne] = loc1;
                this._map[loc1.propertyTwo] = loc1;
                this._map[loc1.propertyThree] = loc1;
                this._map[loc1.propertyFour] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_pet_manual.json");
            this.write(loc1);
            return;
        }

        public getInfoById(arg1: int): PetManualInfo
        {
            return this._map[arg1];
        }

        public getSkillArrayById(arg1: int): Array<any>
        {
            var loc1=[];
            var loc2=this.getInfoById(arg1);
            loc1.push(SkillConfig.instance.getInfoByName(loc2.propertyOne));
            loc1.push(SkillConfig.instance.getInfoByName(loc2.propertyTwo));
            loc1.push(SkillConfig.instance.getInfoByName(loc2.propertyThree));
            loc1.push(SkillConfig.instance.getInfoByName(loc2.propertyFour));
            return loc1;
        }

        public getManualList(arg1: int, arg2: int=-1): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            var loc4=this._map;
            for(loc2 of loc4) 
            {
                if (loc1.indexOf(loc2) != -1) 
                {
                    continue;
                }
                if (loc2.category != arg1) 
                {
                    continue;
                }
                if (arg2 == -1) 
                {
                    loc1.push(loc2);
                    continue;
                }
                if (loc2.type != arg2) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public static get instance(): PetManualConfig
        {
            if (PetManualConfig._instance == null) 
            {
                PetManualConfig._instance = new PetManualConfig();
            }
            return PetManualConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: PetManualConfig;
    }
